from rest_framework.permissions import BasePermission
from rest_framework.response import Response


class UserPermission(BasePermission):
    message = {"status":False,'msg':"无权访问1"}   #权限判断的错误信息
    def has_permission(self, request, view):
        print(request.user.role)
        if request.user.role == 3:
            return Response("user")
        return
class ManagerPermission(BasePermission):
    message = {"status":False,'msg':"无权访问2"}
    def has_permission(self, request, view):
        if request.user.role == 2:
            return Response("manager")
        return

class BossPermission(BasePermission):
    message = {"status":False,'msg':"无权访问3"}
    def has_permission(self, request, view):
        if request.user.role == 1:
            return Response("boss")
        return
